﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GuavaData
{
    public class Error : Operator
    {
        // DDL statement for a generic check constraint (Tier 3 foreign key)

        #region Fields
        Operator query;
        public Operator Query
        {
            get { return query; }
            set { query = value; }
        }
        #endregion Fields

        public Error(Operator query)
        {
            if (!(query.isQuery))
                throw new Exception("Cannot perform an error check on objects that are not queries.");

            this.query = query;
        }

        public override void NotifyChange(Operator old, Operator newOp)
        {
            if (this.query == old)
                this.query = newOp;
        }
        public override bool isQuery
        {
            get
            {
                return false;
            }
        }
        public override SqlText Visit(Provider qv)
        {
            return qv.Transform(this);
        }
        public override void Visit(Transform t, Command c)
        {
            t.Expand(this, c);
        }
        public override Operator Clone()
        {
            return new Error(this.query.Clone());
        }

        public override void Visit(Channel c, string table)
        {
            c.MapAliases(this, table);
        }

    }
}
